public class Solution {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if(headA==null&&headB==null){
            return null;
        }
        int lenA=0;
        int lenB=0;
        ListNode pl=headA;
        ListNode ps=headB;
        while(pl!=null){
            lenA++;
            pl=pl.next;
        }
        while(ps!=null){
            lenB++;
            ps=ps.next;
        }
        pl=headA;
        ps=headB;
        int len=lenA-lenB;
       if(len<0){
           pl=headB;
           ps=headA;
           len=lenB-lenA;
       }
        while(len!=0){
           pl=pl.next;
            len--;
           
        } 
       while(pl!=ps){
           pl=pl.next;
           ps=ps.next;
       }
        return pl;
        
    }
}